package hk.ust.cse.comp4981;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.joda.time.DateTime;
import twitter4j.TwitterException;

public class EventDetection {
	//for calculating the time difference
	public static class Time{
		public static long starttime = 0;
		public static long endtime = 0;
		public static long starttime_set = 0;
		public static long endtime_set = 0;
	}
	public static void main(String[] args) throws TwitterException, IOException{
		String sample_input;
		int sample_size = 0;

		
		try 
		{
		BufferedReader brInput = new BufferedReader(new InputStreamReader(System.in)); 
		System.out.print("Please input the time (in hours(int): "); 
		sample_input = brInput.readLine();
		sample_size = Integer.parseInt(sample_input);

		}
		catch(IOException e) 
		{
		}

		start(sample_size);
		
	}
	
	public static void start(int size) throws TwitterException, IOException{
		DateTime start = new DateTime();
		Time.starttime = start.getMillis();
		StreamingAPI.openfile(size);
	}
	
	//print out all the tweets in array list
	//for testing data crawler
	/*public static void test(ArrayList<MyTweet> sanTweets, ArrayList<MyTweet> nyTweets){
		int sanCount = 1;
		System.out.println("San Francisco");
		for (MyTweet san: sanTweets) {
			System.out.println(sanCount + ".");
			san.print();
			sanCount++;
		}
		
		int nyCount = 1;
		System.out.println("New York");
		for (MyTweet ny: nyTweets) {
			System.out.println(nyCount + ".");
			ny.print();
			nyCount++;
		}
		end();
	}*/
	
	public static void end(){
		DateTime end = new DateTime();
		Time.endtime = end.getMillis();
		long diff = Time.endtime -  Time.starttime; //time difference
		System.out.println("Finished consuming tweets.");
		System.out.println("Time cost: " + diff + " (in milliseconds)");
		System.exit(0);
	}
	
}